<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <input type="text" id="ipt">
    <script>
        ipt = document.getElementById("ipt")
        ipt.addEventListener('input', debounce(function(){
            console.log(this.value)
        },500));




        function debounce(fn, wait) {
            let timer = null;
            return function(...args){
                if(timer){
                    clearTimeout(timer);
                    timer = null;
                }
                timer = setTimeout(() => {
                    fn.apply(this,args)
                },wait)
            }
        }

    </script>
</body>

</html>